import { http } from "@/utils/http";

export type ResultType = ReplaceTargetType<any[]>;

// 查询画布
export const fetchCanvasPage = (url: string, params: object) => {
  return http.request<any>({
    url,
    method: "get",
    params: {
      size: -1,
      current: 1,
      ...params,
    },
  });
};

// 重命名
export const fetchRename = (data: { name: string; id: string }) => {
  return http.request<any>({
    url: "/kg-service/canvas/rename",
    method: "post",
    data,
  });
};

// 删除
export const fetchDestroy = (id: string) => {
  return http.request<any>({
    url: "/kg-service/canvas/destroy",
    method: "post",
    params: {
      id,
    },
  });
};

// 分享
export const fetchShare = (data: object) => {
  return http.request<any>({
    url: "/kg-service/canvas/share",
    method: "post",
    data,
  });
};

export const fetchEntitytype = () => {
  return http.request<any>({
    url: "/kg-service/entitytype/page",
    method: "get",
    params: {
      size: -1,
      current: 1,
    },
  });
};

export const fetchEntitytyperel = () => {
  return http.request<any>({
    url: "/kg-service/entitytyperel/page",
    method: "get",
    params: {
      size: -1,
      current: 1,
    },
  });
};
// 条件查询点
export const fetchKeyWordQuery = (params) => {
  return http.request<any>({
    url: "/kg-service/entity/page/query",
    method: "get",
    params: {
      size: 10,
      ...params,
    },
  });
};

// 查询画布信息
export const fetchCanvas = (id) => {
  return http.request<any>({
    url: "/kg-service/canvas/show",
    method: "get",
    params: {
      id,
    },
  });
};

// 保存画布
export const fetchCanvasStore = (data) => {
  return http.request<any>({
    url: "/kg-service/canvas/store",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data,
  });
};

// 根据点查询关系
export const fetchListEntityTypeRel = (data) => {
  return http.request<any>({
    url: "/kg-service/knowledge/graph/listEntityTypeRel",
    method: "post",
    data,
  });
};

// 关系扩展
export const fetchExpansion = (data) => {
  return http.request<any>({
    url: "/kg-service/graphic-analysis/relationship-expansion",
    method: "post",
    data,
  });
};

// 类案分析
export const similarAnalysis = (data) => {
  return http.request<any>({
    url: "/kg-service/graphic-analysis/similar-analysis",
    method: "post",
    data,
  });
};
